package com.dianrui.qiyouriding.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.dianrui.qiyouriding.R;
import com.dianrui.qiyouriding.bean.InvestBean;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

public class IncomeListDetailsAdapter extends BaseAdapter {
    Context context;
    private List<InvestBean> investBeanList;

    public IncomeListDetailsAdapter(Context context, List<InvestBean> investBeanList) {
        this.context = context;
        this.investBeanList = investBeanList;
    }

    public void refresh(List<InvestBean> list) {
        this.investBeanList = list;
        this.notifyDataSetChanged();
    }

    @Override
    public int getCount() {
        return investBeanList.size();
    }

    @Override
    public Object getItem(int position) {
        return investBeanList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        if (convertView != null) {
            holder = (ViewHolder) convertView.getTag();
        } else {
            convertView = LayoutInflater.from(parent.getContext()).inflate(R.layout.income_list_item, null);
            holder = new ViewHolder(convertView);
            convertView.setTag(holder);
        }
        if (null != investBeanList && investBeanList.size() > 0) {
            InvestBean investBean = investBeanList.get(position);
            holder.orderCode.setText(investBean.order_code);
            holder.money.setText("+"+investBean.money);
            holder.number.setText("车辆数量:"+investBean.number);
            holder.createTime.setText(investBean.create_time);
        }


        return convertView;
    }


     class ViewHolder {
        @BindView(R.id.order_code)
        TextView orderCode;
        @BindView(R.id.money)
        TextView money;
        @BindView(R.id.number)
        TextView number;
        @BindView(R.id.create_time)
        TextView createTime;

        ViewHolder(View view) {
            ButterKnife.bind(this, view);
        }
    }
}
